import Cookies from 'js-cookie'

const TokenKey = '3Y_DATA_TOKEN'
const Key = '3Y_DATA_'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}


export function getUserInfo() {
  return Cookies.get(Key + 'USER_INFO') ? JSON.parse(Cookies.get(Key + 'USER_INFO')) : {}
}

export function setUserInfo(info) {
  return Cookies.set(Key + 'USER_INFO', info)
}

export function removeUserInfo() {
  return Cookies.remove(Key + 'USER_INFO')
}



export function getCookie(name) {

  return Cookies.get(name) ? JSON.parse(Cookies.get(Key + name)) : undefined;
}

export function setCookie(name, obj) {
  return Cookies.set(name,obj)
}

export function removeCookie(name) {
  return Cookies.remove(name)
}
